package com.ys.nms.module.business.dal.mysql.localCompanyDevicetType;

import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.module.business.controller.admin.localCompanyDevicetType.vo.CompanyDeviceTypeListReqVO;
import com.ys.nms.module.business.dal.dataobject.localCompanyDevicetType.CompanyDeviceTypeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 设备类型 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface CompanyDeviceTypeMapper extends BaseMapperX<CompanyDeviceTypeDO> {

    default List<CompanyDeviceTypeDO> selectList(CompanyDeviceTypeListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CompanyDeviceTypeDO>()
                .likeIfPresent(CompanyDeviceTypeDO::getName, reqVO.getName())
                .eqIfPresent(CompanyDeviceTypeDO::getParentId, reqVO.getParentId())
                .likeIfPresent(CompanyDeviceTypeDO::getDutyUserName, reqVO.getDutyUserName())
                .eqIfPresent(CompanyDeviceTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CompanyDeviceTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CompanyDeviceTypeDO::getSort));
    }

	default CompanyDeviceTypeDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(CompanyDeviceTypeDO::getParentId, parentId, CompanyDeviceTypeDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(CompanyDeviceTypeDO::getParentId, parentId);
    }

}